package edu.uw.tcss360.group6.gui.MainCards;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import edu.uw.tcss360.group6.gui.GUI;
import edu.uw.tcss360.group6.model.*;

/**
 * Created with IntelliJ IDEA.
 * edu.uw.tcss360.group6.model.User: Lemtzas
 * Author: Mais Abdulwahab
 * Date: 2/20/13
 * Time: 9:46 PM
 * To change this template use File | Settings | File Templates.
 */
@SuppressWarnings("serial")
public class JudgeSplashPanel extends MainCard {
	
	private Entry[] user_entry;
	

	
    public JudgeSplashPanel() {
        super();
        this.setLayout(new GridLayout(20,1));
        add(new JLabel("Judge Splash Page"));
        add(new JLabel("(Contestants Entries)"));
        user_entry = Contest.instance().getEntries();
       
        for(int i = 0; i < user_entry.length; i++)
        {	
        		add(new JLabel(user_entry[i].toString()));
        		add(new JLabel("Description: " + user_entry[i].getDescription()));
        		contestantIDButton view_weave = new contestantIDButton(user_entry[i].getContestant().getName()+" Weaving draft", i);
        		view_weave.addActionListener(new ActionListener(){
        		public void actionPerformed(final ActionEvent the_event)
          	  	{
        		  contestantIDButton temp = (contestantIDButton)the_event.getSource();
        		  System.out.println(temp.getButtonID()+ "\n");
        		  GUI.instance().my_main_panel.getWeavingPanel().setWeavingDraft(user_entry[temp.getButtonID()].getWeavingDraft());
          		  GUI.instance().my_main_panel.setCard("weaving-draft");
          		  GUI.instance().setFlag(false);
          	  	}
             });
        	 //view_weave.setBorder(BorderFactory.createEmptyBorder(50, 20, 10, 20));
             this.add(view_weave);
        }
   
    }
    private class contestantIDButton extends JButton {
    	private int my_ID;
    	public contestantIDButton(String my_name, int the_ID)
    	{
    		super(my_name);
    		my_ID = the_ID;
    	}
    	public int getButtonID()
    	{
    		return my_ID;
    	}
    	
    }
    
}

